package caiziyou.com.designpattern.prototype.deepclone;

public class Client {

	public static void main(String[] args) throws CloneNotSupportedException {
		// 通过重写clone 方法实现深拷贝，
		System.out.println("重写clone方法实现深度复制");
		DeepCloneTarget deepCloneTarget = new DeepCloneTarget("name", "累型");
		DeepProtoType p = new DeepProtoType("name", 1, deepCloneTarget);
		DeepProtoType p2 = (DeepProtoType) p.clone();

		System.out.println(p == p2);
		System.out.println(p.getDeepCloneTarget() == p2.getDeepCloneTarget());

		// 通过序列化方法实现深度复制，推荐使用
		System.out.println("序列化方法实现深度复制，推荐使用");
		p2 = (DeepProtoType) p.clone();

		System.out.println(p == p2);
		System.out.println(p.getDeepCloneTarget() == p2.getDeepCloneTarget());
	}
}
